package com.seal.tsms.exam.controller;

import com.seal.tsms.base.controller.BaseController;
import com.seal.tsms.base.service.BaseService;
import com.seal.tsms.exam.entity.Stage;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by accp on 2016/6/6.
 */
@Controller
@RequestMapping("/stage")
public class StageController extends BaseController<Stage,String> {
    @Override
    @Autowired
    @Qualifier("stageServiceImpl")
    public void setSelfService(BaseService<Stage, String> selfService) {
        super.setSelfService(selfService);
    }
    @RequestMapping(value = "/save",method = RequestMethod.GET)
    public String create(){
        return "exam/stage/add";
    }
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
    public String save(Stage stage){
        getSelfService().save(stage);
        return "ok";
    }
    @RequestMapping(value = "stageListAjax")
    @ResponseBody
    public List<Stage> ajaxList(){
        return (List<Stage>) getSelfService().list(DetachedCriteria.forClass(Stage.class),null);
    }
}
